<?php
/**
 * Description of Gateway
 *
 * @author yeyupl
 */
include LIB_DIR . "amfphp/core/amf/app/Gateway.php";

class amfphp{
    private static $instance = null;    
    public static function getInstance(){
        if (is_null(self::$instance)) {
            self::$instance = new amfphp();
            self::$instance->amfphp = new Gateway();
            self::$instance->amfphp->setClassPath(SERVICE_DIR);
            self::$instance->amfphp->setClassMappingsPath(SERVICE_VO_DIR);
        }
        return self::$instance;
    }

    public function setProduction($product = true) {
        $this->amfphp->disableDebug($product);
        $this->amfphp->disableStandalonePlayer($product);        
        if ($product) {
            $this->amfphp->setErrorHandling(0);
        } else {
            $this->amfphp->setErrorHandling(E_ALL ^ E_NOTICE);
            $this->amfphp->logIncomingMessages(AMF_IN_DIR);
            $this->amfphp->logOutgoingMessages(AMF_OUT_DIR);
        }
    }

    public function setGzip($limitSize = 51200) {
        $this->amfphp->enableGzipCompression($limitSize);
    }

    public function run() {
        $this->amfphp->service();
    }
}
?>
